package cn.fl.custpay.transform;

import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.custpay.dto.CmmCstAddressDTO;
import cn.fl.custpay.vo.CmmCstAddressVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 通讯录记录 转换器
 * @Description: VO是客户端传递数据到服务端进行转换的数据 
 * @Description: VO转换数据变成DTO传递到服务端 
 * @Description: VO不能在服务端出现
 */
public class CmmCstAddressVOTransform {


	/**
	 * DTO 转  VO
	 * @param dto CmmCstAddressDTO
	 * @return CmmCstAddressVO
	 */
	public static CmmCstAddressVO toVO(CmmCstAddressDTO dto) {
		CmmCstAddressVO  vo = null;
		if (dto != null) { 
			vo = new CmmCstAddressVO();
			vo.setId(dto.getId());
			vo.setPhoneName(dto.getPhoneName());//姓名
			vo.setPhoneCompany(dto.getPhoneCompany());//公司
			vo.setPhoneAddress(dto.getPhoneAddress());//地址
			vo.setMp1(dto.getMp1());//手机号1
			vo.setMp2(dto.getMp2());//手机号2
			vo.setMp3(dto.getMp3());//手机号3
			vo.setMp4(dto.getMp4());//手机号4
			vo.setClientName(dto.getClientName());//客户姓名
			vo.setClientPhone(dto.getClientPhone());//客户手机号
			vo.setAppCode(dto.getAppCode());
			vo.setOsCd(dto.getOsCd());
			vo.setCrtTm(dto.getCrtTm());//创建时间
			vo.setCrtUsrId(dto.getCrtUsrId());//创建人
			vo.setMdfTm(dto.getMdfTm());//修改时间
			vo.setMdfUsrId(dto.getMdfUsrId());//修改人
		}
		return vo;
	}

	/**
	 * VO 转 DTO
	 * @param vo CmmCstAddressVO
	 * @return CmmCstAddressDTO
	 */
	public static CmmCstAddressDTO toDTO(CmmCstAddressVO vo) {
		CmmCstAddressDTO dto = null;
		if (vo != null) {
			dto = new CmmCstAddressDTO();
			dto.setId(vo.getId());
			dto.setPhoneName(vo.getPhoneName());//姓名
			dto.setPhoneCompany(vo.getPhoneCompany());//公司
			dto.setPhoneAddress(vo.getPhoneAddress());//地址
			dto.setMp1(vo.getMp1());//手机号1
			dto.setMp2(vo.getMp2());//手机号2
			dto.setMp3(vo.getMp3());//手机号3
			dto.setMp4(vo.getMp4());//手机号4
			dto.setClientName(vo.getClientName());//客户姓名
			dto.setClientPhone(vo.getClientPhone());//客户手机号
			dto.setAppCode(vo.getAppCode());
			dto.setOsCd(vo.getOsCd());
			dto.setCrtTm(vo.getCrtTm());//创建时间
			dto.setCrtUsrId(vo.getCrtUsrId());//创建人
			dto.setMdfTm(vo.getMdfTm());//修改时间
			dto.setMdfUsrId(vo.getMdfUsrId());//修改人
		}
		return dto;
	}
	
	/**
	 * DTO集合 转 VO集合
	 * @param list List<CmmCstAddressDTO>
	 * @return List<CmmCstAddressVO>
	 */
	public static List<CmmCstAddressVO> toVOList(List<CmmCstAddressDTO> list) {
		List<CmmCstAddressVO>  voList = new ArrayList<CmmCstAddressVO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (CmmCstAddressDTO dto : list) {
				voList.add(toVO(dto));
			}
		}
		return voList;
	}
	
	/**
	 * VO集合 转 DTO集合
	 * @param list List<CmmCstAddressVO>
	 * @return List<CmmCstAddressDTO>
	 */
	public static List<CmmCstAddressDTO> toDTOList(List<CmmCstAddressVO> list) {
		List<CmmCstAddressDTO>  dtoList = new ArrayList<CmmCstAddressDTO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (CmmCstAddressVO vo : list) {
				dtoList.add(toDTO(vo));
			}
		}
		return dtoList;
	}
}
